home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7261 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  75 lines

  1. Path: titan.fullerton.edu!etezadi
  2. From: etezadi@titan.fullerton.edu (Syrous Etezadi Amoli)
  3. Newsgroups: comp.lang.c++
  4. Subject: Help me.  What is wrong with the following linked list ?
  5. Date: 22 Feb 1996 08:55:10 GMT
  6. Organization: California State University at Fullerton
  7. Message-ID: <4ghb1e$9av@nuke.csu.net>
  8. NNTP-Posting-Host: ecs.fullerton.edu
  9.  
  10. Hi
  11.  
  12. Would you tell me why I get a lot of errors from the following code which
  13. implements a linked list with TListImp in BC++ 4.5 ? 
  14.  
  15. Any hint is greatly appreciated.
  16.  
  17. Thanks
  18.  
  19.  
  20. #include <classlib\listimp.h>
  21. #include <iostream.h>
  22. #include <String.h>
  23.  
  24. void main()
  25. {
  26.  
  27.  
  28. class CIndexListElement : public: string{
  29.  private:
  30.   string subject;
  31.   long start;
  32.   long end;
  33.  public:
  34.  
  35.   DWORD GetStart(void) {return start;};
  36.   DWORD GetEnd(void) { return end;};
  37.   string GetSubject(void) {return subject;};
  38.   void SetStart(DWORD x) {start = x;};
  39.   void SetEnd(DWORD x) {end = x;};
  40.   void SetSubject(string s) { subject = s;};
  41.   private:
  42.  
  43.  
  44. };
  45. TListImp<CIndexListElement> m_SubjectList;
  46.  
  47. CIndexListElement *new_entry=  new CIndexListElement;
  48. new_entry->SetSubject("1st subject");
  49. new_entry->SetEnd(1);
  50. new_entry->SetStart(1);
  51. m_SubjectList.Add(new_entry);
  52. new_entry->SetSubject("2ND subject");
  53. new_entry->SetEnd(2);
  54. new_entry->SetStart(2);
  55. m_SubjectList.Add(new_entry);
  56. new_entry->SetSubject("3RD subject");
  57. new_entry->SetEnd(3);
  58. new_entry->SetStart(3);
  59. m_SubjectList.Add(new_entry);
  60.  
  61. TListIteratorImp<cIndexListElement> next(m_SubjectList);
  62. cout << "\n The stored items are:\n" << next++;
  63.  
  64. while (next)
  65.   cout << ", " << next++;
  66. cout << endl;
  67. }
  68.  
  69. --
  70.   
  71.  
  72. --------------
  73. Syrous Etezadi Amoli (SEA)
  74. etezadi@titan.fullerton.edu
  75.